#ifndef _KNOWLEDGEBASE_H_
#define _KNOWLEDGEBASE_H_
#include <list>
#include <set>
#include <iterator>

class BaseCodeAttr
{
private:
	TCHAR baseCode[BASE_CODE_LEN];
	INT frequency;
public:
	BaseCodeAttr(CONST LPTSTR lpCode,INT freq);
	BaseCodeAttr(CONST BaseCodeAttr& baseCode);
	LPTSTR GetCode();
	INT CompareTo(CONST BaseCodeAttr& baseCode) CONST;
	BaseCodeAttr& operator=(CONST BaseCodeAttr& baseCode);
	BOOL operator > (CONST BaseCodeAttr& baseCode) CONST;
	BOOL operator < (CONST BaseCodeAttr& baseCode) CONST;
	BOOL operator == (CONST BaseCodeAttr& baseCode) CONST;
	BOOL operator >= (CONST BaseCodeAttr& baseCode) CONST;
	BOOL operator <= (CONST BaseCodeAttr& baseCode) CONST;
	BOOL operator != (CONST BaseCodeAttr& baseCode) CONST;
	VOID CopyFrom(CONST BaseCodeAttr& baseCode);
};

class ImmData;
class KnowledgeProcess
{
private:
	CONST std::list<LPBYTE>* lpCodeList;
	ImmData* lpImmData;
private:
	static std::list<LPBYTE> preResult;
	static UINT preInputLen;
public:
	static BOOL Multiple;
public:
	KnowledgeProcess(ImmData* lpImmData);
	UINT SelectTheFirst();
	UINT TranslateInput();
	static VOID KnowledgeFilter(CONST std::list<LPBYTE>& byteList,CONST std::wstring& comp_str,TCHAR pinYin,std::list<LPBYTE>& result);
	static VOID GetBaseCode(CONST std::list<LPBYTE>& byteList,UINT fromPos,std::set<BaseCodeAttr,std::greater<BaseCodeAttr> >& result);
	static UINT GetFrequency(CONST LPBYTE lpByte);
	static TCHAR GetPinyin(CONST LPBYTE lpByte);
	static CONST LPTSTR GetWord(CONST LPBYTE lpByte);
	static CONST LPTSTR GetWordCode(CONST LPBYTE lpByte);
	static BOOL Str1BeginWithStr2(CONST std::wstring& str1,CONST std::wstring& str2);
};
#endif
